package www.yingdi365.com.viewholder;

import android.support.annotation.LayoutRes;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;

import www.yingdi365.com.R;
import www.yingdi365.com.activity.SheZhiYYActivity;
import www.yingdi365.com.model.MusicsBean;

/**
 * Created by Administrator on 2017/3/28 0028.
 */
public class SheZhiYYViewHolder extends BaseViewHolder<MusicsBean> {

    private final TextView textName;
    private final ImageView imageBoFang;
    private MusicsBean data;

    public SheZhiYYViewHolder(ViewGroup parent, @LayoutRes int res) {
        super(parent, res);
        textName = $(R.id.textName);
        imageBoFang = $(R.id.imageBoFang);
        imageBoFang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (data.isBoFang()){
                    ((SheZhiYYActivity)getContext()).stopPlay();
                }else {
                    ((SheZhiYYActivity)getContext()).palyVoice(getDataPosition());
                }
            }
        });
    }

    @Override
    public void setData(MusicsBean data) {
        super.setData(data);
        this.data=data;
        textName.setText(data.getFile().getName());
        if (data.isBoFang()){
            imageBoFang.setImageResource(R.mipmap.zanting);
        }else {
            imageBoFang.setImageResource(R.mipmap.bofang);
        }
        if (data.isXuanZhong()){
            textName.setTextColor(getContext().getResources().getColor(R.color.basic_color));
        }else {
            textName.setTextColor(getContext().getResources().getColor(R.color.light_black));
        }
    }
    
}
